<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>抱抱堂-中国爆给力</title>
    <meta name="renderer" content="webkit">
    <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="{:C('IMG_PATH')}static/css/main.css?x=12">
    <style>
        .linear-bg {
            background-image:url({:C('IMG_PATH')}static/hd/oly/bg.png);
            background-color: #E30B20;
            background-position: center;
            background-size: 100% auto;
            background-repeat: repeat-y;
        }
        section.prize{
            position: relative;
        }
        .silk{
            position:absolute;
            top:-5vh;
        }
        .silk img{
            width: 100%;
        }
        .slogan{
            position: absolute;
            text-align: center;
            top:5vh;
            width: 100vw;
        }
        .slogan img{
            width: 90%;
        }
        .gold{
            position: absolute;
            text-align: center;
            top:30vh;
            width: 100vw;
        }
        .gold img{
            width: 70%;
        }
        .touch{
            position: absolute;
            text-align: right;
            top:25vh;
            left: -5vw;
            width: 100vw;
        }
        .touch img{
            width: 50%;
        }
        .content{
            position: absolute;
            text-align: center;
            top:72vh;
            width: 100vw;
        }
        .content p{
            width: 60vw;
            font-size: 18px;
            color:#fff;
            display: inline-block;
        }
        .content p:last-child{
            margin-top: 20px;
        }

        .slogan2{
            position: absolute;
            text-align: center;
            top:2vh;
            left:1vw;
            width: 45vw;
        }
        .slogan2 img{
            width: 90%;
        }
        .share2{
            position: absolute;
            text-align: center;
            top:0vh;
            right:1vw;
            width: 45vw;
        }
        .share2 img{
            width: 90%;
        }
        .gold2{
            position: absolute;
            text-align: center;
            top:20vh;
            width: 100vw;
        }
        .gold2 img{
            width: 70%;
        }
        .gold2 p{
            padding:0 10vw;
            font-size: 18px;
            color: #fff;
        }
        .gold2 h1{
            color: #fff;
            font-size: 18px;
            border-top: 1px solid #fff;
            line-height: 1px;
            margin-top: 28px;
        }
        .gold2 h1 span{
            background-color: #EF582D;
            padding: 0 20px;
        }
        .gold2 div{
            margin-top: 20px;
        }
        .gold2 div span{
            display: inline-block;
            width: 24vw;
        }
        .btn{
            background: url({:C('IMG_PATH')}static/hd/oly/btn1.png);
            background-position: center;
            background-size: 100% auto;
            border: none;
            height:60px;
            width: 120px;
        }
        .btn1{
            background: url({:C('IMG_PATH')}static/hd/oly/btn2.png);
            background-position: center;
            background-size: 100% auto;
            font-size: 1px;
            height:60px;
            width: 120px;
        }
        .btn2{
            background: url({:C('IMG_PATH')}static/hd/oly/notice4.png);
            background-position: center;
            background-size: 100% auto;
            font-size: 1px;
            height:59px;
            width: 161px;
        }
        .brief_title{
            padding: 0;
        }
        .brief_title img{
            width: 70%;
        }
        div.main{
            top:0;
            background-color: rgba(0, 0, 0, 0.7);
        }
        section.card{
            margin-top: 100px;
            background-color: #FEC631;
            border: 1px solid #793612;
        }
        section.warning{
            background-color: #fff;
            border:none;
        }
        section.card > *{
            position: relative;
            top:-26px;
        }
        section.warning .brief_title img{
            border-radius: 999px;
            width: 100px;
            height: 100px;
            border: 1px solid #B0B0B0;
        }
        section.warning > *{
            position: relative;
            top:-50px;
        }
        section.warning .brief_content p:first-child{
            color: #E30B20;
            font-weight: bolder;
        }
        section.warning .brief_content p:last-child{
            color: #E30B20;
            font-size: 13px;
            padding: 10px 0;
            border-bottom: 1px dotted #C2C2C2
        }

        section input{
            border-color: #793612 !important;
        }
        .gift_btn1{
            text-align: center;
            padding: 15px 0 0 0;
        }
        .brief_content{
            color: #793612;
            font-size: 20px;
        }
        .boom{
            position: absolute;
            text-align: center;
            top:25vh;
            width: 100vw;
            display: none;
        }
        .boom img{
            width: 70%;
        }

        .logo2{
            position: absolute;
            text-align: center;
            top:2vh;
            right:4vw;
            width: 50vw;
        }
        .logo2 img{
            width: 100%;
        }
        .logo3{
            position: absolute;
            text-align: center;
            top:0;
            left:10vw;
            width: 45vw;
        }
        .logo3 img{
            width: 100%;
        }
        .logo4{
            position: absolute;
            text-align: right;
            top:17vh;
            right:5vw;
            width: 45vw;
        }
        .logo4 img{
            width: 50%;
        }
        .gold3{
            position: absolute;
            text-align: center;
            top:18vh;
            width: 90vw;
            padding: 0 5vw;
        }
        .gold3 img{
            width: 100%;
        }
        .gold3 h1{
            text-align: center;
            color: #fff;
            font-size: 20px;
            line-height: 20px;
            margin-top: 3vh;
            font-weight: bolder;
        }
        .gold3 h2{
            color: #fff;
            font-size: 13px;
            border-top: 1px solid #fff;
            line-height: 1px;
            margin-top: 4vh;
            text-align: center;
            font-weight: normal;
        }
        .gold3 h2 span{
            background-color: #F16F34;
            padding: 0 10px;
        }
        .gold3 div{
            margin-top: 3vh;
        }
        .gold3 div span.l1{
            display: inline-block;
            width: 28vw;
            text-align: center;
            margin-right: 1vw;
        }
        .gold3 div span.l2{
            display: inline-block;
            width: 20.6vw;
            text-align: center;
            margin-right: 1vw;
        }
        .gold3 div span.l3{
            display: inline-block;
            width: 33vw;
            text-align: center;
            margin-right: 1vw;
            color: #fff;
        }
        section.loading{
            margin-top: 3vh;
            height: 10px;
            width: 100%;
            border-radius: 100px;
            background-color: #6C1406;
            text-align: left;
        }
        section.loading div{
            width: 10%;
            height: 10px;
            background-color: #F7CD35;
            border-radius: 100px;
        }

        .animate1{
            -webkit-animation:animations1 0.5s ease-out forwards;
            animation:animations1 0.5s ease-out forwards;
        }
        @-webkit-keyframes animations1{
            0%{opacity:0;top:-50vh}
            90%{opacity:1;top:0}
            100%{opacity:1;top:-5vh}
        }
        @keyframes animations1{
            0%{opacity:0;top:-50vh}
            90%{opacity:1;top:0}
            100%{opacity:1;top:-5vh}
        }

        .animate2{
            -webkit-animation:animations2 0.5s ease-out forwards;
            animation:animations2 0.5s ease-out forwards;
        }
        @-webkit-keyframes animations2{
            0%{opacity:0;top:0}
            90%{opacity:1;top:35vh}
            100%{opacity:1;top:30vh}
        }
        @keyframes animations2{
            0%{opacity:0;top:0}
            90%{opacity:1;top:35vh}
            100%{opacity:1;top:30vh}
        }

        .animate3{
            -webkit-animation:animations3 0.5s ease-out forwards;
            animation:animations3 0.5s ease-out forwards;
        }
        @-webkit-keyframes animations3{
            0%{opacity:0;width:40%}
            90%{opacity:1;width:100%}
            100%{opacity:1;width:90%}
        }
        @keyframes animations3{
            0%{opacity:0;width:40%}
            90%{opacity:1;width:100%}
            100%{opacity:1;width:90%}
        }
    </style>
</head>
<body class="linear-bg">
<!--游戏页-->
<section class="prize playground" style="display: none;">
    <div class="silk" style="opacity: 0"><img src="{:C('IMG_PATH')}static/hd/oly/silk.png"></div>
    <div class="slogan"><img style="opacity: 0" src="{:C('IMG_PATH')}static/hd/oly/slogan.png"></div>
    <div class="gold" style="opacity: 0"><img class="tap_me" src="{:C('IMG_PATH')}static/hd/oly/bbt1.png"></div>
    <div class="touch" style="display:none"><img src="{:C('IMG_PATH')}static/hd/oly/touch.gif"></div>
    <div class="boom oly_animation" style="display:none"><img src="{:C('IMG_PATH')}static/hd/oly/boom1.png"></div>
    <div class="content" style="display:none">
        <p>获得由抱抱堂提供的iPhone 7 plus 500台</p>
        <p><button class="btn gotit-btn"></button></p>
    </div>
</section>

<!--loading页-->
<section class="prize loading-page" style="display: none;">
    <div class="logo3"><img src="{:C('IMG_PATH')}static/hd/oly/logo3.png"></div>
    <div class="logo2"><img src="{:C('IMG_PATH')}static/hd/oly/logo2.png"></div>
    <div class="logo4"><img src="{:C('IMG_PATH')}static/hd/oly/logo.png"></div>
    <div class="gold3">
        <h1>鸣谢</h1>
        <h2><span>金牌合作伙伴</span></h2>
        <div>
            <span class="l1"><img src="{:C('IMG_PATH')}static/hd/oly/l11.png"></span>
            <span class="l1"><img src="{:C('IMG_PATH')}static/hd/oly/l12.png"></span>
            <span class="l1"><img src="{:C('IMG_PATH')}static/hd/oly/l13.png"></span>
        </div>
        <h2><span style="background-color:#F06631">爆给力合作伙伴</span></h2>
        <div>
            <span class="l1"><img src="{:C('IMG_PATH')}static/hd/oly/l21.png"></span>
            <span class="l1"><img src="{:C('IMG_PATH')}static/hd/oly/l22.png"></span>
            <span class="l1"><img src="{:C('IMG_PATH')}static/hd/oly/l23.png"></span>
        </div>
        <h2><span style="background-color:#EB3622">爆给力推广平台</span></h2>
        <div>
            <span class="l2"><img src="{:C('IMG_PATH')}static/hd/oly/l31.png"></span>
            <span class="l2"><img src="{:C('IMG_PATH')}static/hd/oly/l32.png"></span>
            <span class="l2"><img src="{:C('IMG_PATH')}static/hd/oly/l33.png"></span>
            <span class="l2"><img src="{:C('IMG_PATH')}static/hd/oly/l34.png"></span>
            <span class="l2"><img src="{:C('IMG_PATH')}static/hd/oly/l35.png"></span>
            <span class="l2"><img src="{:C('IMG_PATH')}static/hd/oly/l36.png"></span>
            <span class="l2"><img src="{:C('IMG_PATH')}static/hd/oly/l37.png"></span>
            <span class="l2"><img src="{:C('IMG_PATH')}static/hd/oly/l38.png"></span>
        </div>
        <div>
                <span class="l3">
                    <p>爆给力短视频平台</p>
                    <img src="{:C('IMG_PATH')}static/hd/oly/l51.png">
                </span>
                <span class="l3">
                    <p>爆给力直播平台</p>
                    <a href="http://www.douyu.com/common/baomihua/">
                        <img src="{:C('IMG_PATH')}static/hd/oly/l53.png">
                    </a>
                </span>
        </div>
        <section class="loading">
            <div></div>
        </section>
    </div>
</section>

<!--个人中心页-->
<div class="main personal_info" style="display:none;opacity:1">
    <form name="phone" method="post" class="form_profile">
        <section class="gift card">
            <div class="brief_title">
                <img src="{:C('IMG_PATH')}static/hd/oly/info.png">
            </div>
            <section class="brief_content">
                <p>请您完善个人信息</p>
            </section>
            <section class="gift_personal_info">
                <p><input type="text" name="real_name" placeholder="真实姓名" /></p>
                <p><input name="phone_number" type="number" placeholder="手机号" /></p>
                <p class="captcha_box"><input name="captcha_number" type="number" placeholder="短信验证码" /><button st="1" class="long-yellow-btn captcha">获取验证码</button></p>
                <p><textarea name="address" placeholder="邮寄地址"></textarea></p>
                <input type="hidden" class="cid-input" name="card_code" />
                <div class="gift_btn1">
                    <button class="btn btn1 id-gotit-btn"></button>
                </div>
            </section>
        </section>
    </form>
</div>

<!--获奖规则页-->
<div class="main success_notice" style="opacity: 1;display: none">
    <section class="gift card warning">
        <div class="brief_title">
            <img src="{:C('IMG_PATH')}static/hd/oly/info.png">
        </div>
        <section class="brief_content">
            <p>恭喜您获得一等奖，哈哈哈</p>
            <p>活动规则在这里</p>
        </section>
        <section class="brief_content">
            <img src="{:C('IMG_PATH')}static/hd/oly/notice1.png" style="width:50%">
        </section>
        <section style="padding:0 15px;">
            <p>奖品已经放入您抱抱堂账户，请参照以下步骤领取。</p>
            <p>1. 在微信中搜索“抱抱堂爆米花”</p>
            <p><img src="{:C('IMG_PATH')}static/hd/oly/notice2.png" style="width:100%"></p>
            <p>2. 点击右下角“摇摇乐领奖”</p>
            <p><img src="{:C('IMG_PATH')}static/hd/oly/notice3.png" style="width:100%"></p>
            <div class="gift_btn1">
                <button class="btn btn2 iknowwhatitis"></button>
            </div>
        </section>
    </section>
</div>

<!--分享页-->
<section class="prize share_face" style="opacity: 1;display: none">
    <div class="slogan2"><img src="{:C('IMG_PATH')}static/hd/oly/logo2.png"></div>
    <div class="share2"><img src="{:C('IMG_PATH')}static/hd/oly/share_arrow.png"></div>
    <div class="gold2">
        <img class="share2_p1" src="{:C('IMG_PATH')}static/hd/oly/share_a1.png">
        <img class="share2_p2" src="{:C('IMG_PATH')}static/hd/oly/share_a2.png">
        <p class="share2_p3">经抱抱堂学霸联盟鉴定，你上知天文能捡瓦下知地理会掏沟，爆聪明！快去向小伙伴炫耀一下！</p>
    </div>
</section>

<!--底部logo-->
<footer class="white footer_logo" style="z-index:1000;display: none;"><img src="{:C('IMG_PATH')}static/hd/oly/logo.png" /></footer>
</body>
<script src="{:C('IMG_PATH')}static/zepto.min.js"></script>
<script>
    (function(){
        //界面剧情
        $(function(){
            showLoadingpage();
        });

        function showLoadingpage(){
            $('.loading-page').show();
            var loadingbar = $('.loading-page .loading div');
            var initWidth = 10;

            var loadingInterval = setInterval(function(){
                if (initWidth == 100){
                    clearInterval(loadingInterval);
                    $('.loading-page').hide();
                    showPlayground();
                    return;
                }
                loadingbar.css('width', initWidth + '%');
                initWidth ++;
            }, 50);
        }

        function showPlayground(){
            $('.playground').show();
            $('.footer_logo').show();
            var silk = $('.silk');
            var gold = $('.gold');
            var slogan = $('.slogan img');

            silk.addClass('animate1');
            gold.addClass('animate2');
            setTimeout(function(){
                slogan.addClass('animate3');
                $('.touch').show();
            }, 500);
        }

        var boom_img = $($(".oly_animation img").get(0));
        var gold_img = $($(".tap_me").get(0));
        var actionHandle = 0;
        var frameList = ['boom1','boom2','boom3','boom4','boom5','boom6','boom7','boom8'];
        var prize_medal = ['bbt1.png','bbtn1.png','bbtn2.png','bbtn3.png','bbtn4.png'];
        var prizeInfo = {};

        function animation(action, handle){
            var picNumber = 0;
            if (action == "start") {
                if (!actionHandle) {
                    actionHandle = setInterval(function(){
                        if (picNumber >= frameList.length) {
                            picNumber = 0;
                            animation("stop", handle);
                        }
                        boom_img.attr('src', "{:C('IMG_PATH')}static/hd/oly/" + frameList[picNumber] + '.png');
                        picNumber++;
                    }, 60);
                }
            }
            if (action == "stop") {
                clearInterval(actionHandle);
                picNumber = 0;
                if(handle){
                    handle();
                }
            }
        }
        var tapRate = setInterval(function(){
            if($('.playground').css('display') != 'none'){
                if(tapCount == lastCount){
                    tapCount = 0;
                    lastCount = 0;
                    gold_img.attr('src', "{:C('IMG_PATH')}static/hd/oly/bbt1.png");
                }
                lastCount = tapCount;
            }
        }, 500);

        var tapCount = 0;
        var lastCount = 0;

        gold_img.on('touchstart', function (e) {
            gold_img.css('width', '67vw');
            e.preventDefault();
        });
        gold_img.on('touchend', function (e) {
            e.preventDefault();
            gold_img.css('width', '70vw');
            if (tapCount == 15){
                clearInterval(tapRate);
                getPrize();
            }

            tapCount++;

            if (tapCount == 5) {
                gold_img.attr('src', "{:C('IMG_PATH')}static/hd/oly/" + 'bbt2.png');
            }
            if (tapCount == 10) {
                gold_img.attr('src', "{:C('IMG_PATH')}static/hd/oly/" + 'bbt3.png');
            }
        });

        function messageShow(kind, data) {

            $('.content').show();
            var p = $('.content p');

            if (kind == 0) {
                $(p.get(0)).html(data.congratulations + data.money + ' <span>元</span>');
                gold_img.attr('src', "{:C('IMG_PATH')}static/hd/oly/" + prize_medal[data.prizes_grade]);
                $(".gotit-btn").on("click", showNotice);
            }
            if (kind == 1) { //中奖出错
                $(p.get(0)).html('很可惜 这次没有中奖');
                $(".gotit-btn").on("click", function(){
                    window.location.reload();
                });
//            $(p.get(1)).hide();
            }

            if (kind == 2) { //没中奖
                $(p.get(0)).html(data.congratulations);
//            $(p.get(1)).hide();
                $(".gotit-btn").on("click", function(){
                    window.location.reload();
                });
            }
            if (kind == 3) { //红包已用完
                $(p.get(0)).html('今天红包已经摇完');
//            $(p.get(1)).hide();
                $(".gotit-btn").on("click", function(){
                    window.location.reload();
                });
            }

            if (kind == 4) { //中链接类奖品
                $(p.get(0)).html(data.congratulations ? data.congratulations : data.title);
                gold_img.attr('src', "{:C('IMG_PATH')}static/hd/oly/" + prize_medal[data.prizes_grade]);
                $(".gotit-btn").on("click", function(){
                    window.location.href = data.center_url;
                });
            }
            if (kind == 5) { //中实体奖品
                $(p.get(0)).html(data.congratulations ? data.congratulations : data.title);
                gold_img.attr('src', "{:C('IMG_PATH')}static/hd/oly/" + prize_medal[data.prizes_grade]);
                $(".gotit-btn").on("click", function(e){
                    var param = data;
                    param['cid'] = data.card_code;
                    verifyProcess(0, param);
                });
            }

            if (kind == "profile") {
                $('.personal_info').show();
                $('.personal_info input.cid-input').attr("value", data.card_code);
                var form = $(".form_profile");
                form.submit(function(e){
                    e.preventDefault();
                });

                $(".captcha").on("click", function(e){
                    verifyProcess(1, form);
                });
                $(".id-gotit-btn").on("click", function(e){
                    verifyProcess(2, form);
                });
            }
        }

        function getPrize(){
            // 获取红包
            $.ajax({
                url : "{:U('Huodong/api/shake')}",
                cache : false,
                type : "POST",
                dataType : "json",
                data : {
                    'long' : longitude,
                    'lat' : latitude
                },
                success : function(msg, textStatus){
                    gold_img.off();
                    $('.touch').hide();
                    if (msg.errcode == 0) {
                        // 中奖
//                    var d = {
//                        title : "123",
//                        center_pic : "http://ww2.sinaimg.cn/orj480/61e89b74jw1f4ycyamt2wj20hi0c6mz7.jpg",
//                        description : "hello world",
//                        card_code : 123
//                    };

                        $(".oly_animation").show();
                        animation("start", function () {
                            $(".oly_animation").hide();
                        });
//                    messageShow(5, d);
                        messageShow(msg.data.status, msg.data.prizes);
                        prizeInfo = msg.data.prizes;
                        return;
                    } else if (msg.errcode == 504) {
                        window.location.href = msg.jumpUrl;
                    } else if (msg.errcode == 403) {
                        alert(msg.errmsg);
                    }
                },
                error : function(){

                }
            });
        }

        var checkForm = {
            phoneNumber : function(pn) {
                if (pn.length == 11) {
                    return true;
                }
                return false;
            },
            captchaNumber : function(pn) {
                if (pn.length == 6) {
                    return true;
                }
                return false;
            },
            captchaTime : 1,
            captchaBtn : function(status, btn) {
                var time = 60;

                if (status == 0) {
                    clearTimeout(captchaTime);
                    btn.innerHTML = "获取手机验证码";
                    $(btn).attr("st", "1");
                    return;
                }

                var countDown = function() {
                    if (time > 0 && $(btn).attr("st") == 0) {
                        if (status == 1) {
                            btn.innerHTML = time + "秒剩余";
                        }
                        time--;
                        captchaTime = setTimeout(countDown, 1000);
                    } else {
                        checkForm.captchaBtn(0, btn);
                    }
                }

                $(btn).attr("st", "0");
                countDown();
            },
            realName : function(pn) {
                if (pn.length >= 2) {
                    return true;
                }
                return false;
            },
            address : function(pn) {
                if (pn.length >= 6) {
                    return true;
                }
                return false;
            },
            idcode : function(pn) {
                return true;
                if (pn.length >= 15) {
                    return true;
                }
                return false;
            }
        };

        function showNotice(){
            var notice = $('.success_notice');
            $('.success_notice .brief_title img').attr('src', prizeInfo.center_pic);
            var title = $('.success_notice .brief_content p').get(0);
            var intro = $('.success_notice .brief_content p').get(1);

            title.innerHTML = prizeInfo.congratulations ? prizeInfo.congratulations : prizeInfo.title;
            intro.innerHTML = prizeInfo.description ? prizeInfo.description: '';

            $('.iknowwhatitis').on('click', function(e){
                showShareScreen();
                notice.hide();
            });
            notice.show();
        }

        function showShareScreen(){
            $('.playground').hide();
            $('.share_face').show();

            var randomNumber = Math.floor(Math.random()*100 % 8);

            $('.share2_p1').attr('src', pics[randomNumber] + '1.png');
            $('.share2_p2').attr('src', pics[randomNumber] + '2.png');
            $('.share2_p3').html(contents[randomNumber]);

            wx.onMenuShareTimeline({
                title: titles[1].replace('[ggg]', names[randomNumber]),
                link: env.link,
                imgUrl: pics[randomNumber] + '1.png',
                trigger: function (res) {},
                success: function (res) {},
                cancel: function (res) {},
                fail: function (res) {}
            });
            wx.onMenuShareAppMessage({
                title: '中国爆给力',
                link: env.link,
                imgUrl: pics[randomNumber] + '1.png',
                desc: titles[1].replace('[ggg]', names[randomNumber]), // 分享描述
                type: 'link',
                dataUrl: '',
                success: function () {},
                cancel: function () {}
            });
        }

        function verifyProcess(step, data) {
            if (step == 0) { //验证是否具有领取资格
                if (data) {
                    $.ajax({
                        url : "{:U('Portal/api/getPrizes')}",
                        cache : false,
                        type : "POST",
                        dataType : "json",
                        data : {'cid' : data.cid},
                        success : function(msg, textStatus){
                            if (msg.errcode == 0) {
                                if (msg.data.status == 0) {
                                    $('.personal_info').hide();
                                    showNotice();
                                    return;
                                } else if (msg.data.status == 2){
                                    messageShow("profile", data);
                                }
                            } else {
                                alert('奖品领取失败，请稍后重试');
                            }
                        },
                        error : function(){
                            alert('奖品领取失败，请稍后重试');
                        }
                    });
                }
            }

            if (step == 1) { //获取验证码
                if($($('.captcha')[0]).attr("st") == "0"){
                    return;
                }

                var form = data.serializeArray();
                // 验证手机号
                var phoneNumber = "";
                $(form).each(function(index) {
                    if (this.name == "phone_number") {
                        phoneNumber = this.value;
                        return;
                    }
                });

                if (checkForm.phoneNumber(phoneNumber)) {
                    checkForm.captchaBtn(1, $('.captcha')[0]);

                    $.ajax({
                        url : "{:U('Portal/api/getPhoneCaptcha')}",
                        cache : false,
                        type : "POST",
                        dataType : "json",
                        data : {
                            "phone_number" : phoneNumber
                        },
                        success : function(msg, textStatus){
                            if (msg.errcode == 0) {
                                if (msg.data.status == 0) {
                                    alert('验证码下发成功');
                                    return;
                                }
                                if (msg.data.status == 4) {
                                    alert('每天限制3条短信已经用完，有问题请联系客服');
                                    return;
                                }
                                alert('验证码下发失败，请重试');
                                checkForm.captchaBtn(0, $('.captcha')[0]);
                            } else {
                                alert('验证码下发失败，请重试');
                                checkForm.captchaBtn(0, $('.captcha')[0]);
                            }
                        },
                        error : function(){
                            alert('验证码下发失败，请重试');
                            checkForm.captchaBtn(0, $('.captcha')[0]);
                        }
                    });
                } else {
                    alert('手机号码格式错误，请再次输入');
                }
            }

            if (step == 2) {
                var phoneNumber = "";
                var captchaNumber = "";
                var realName = "";
                var address = "";
                var idcode = "";

                var form = data.serializeArray();
                $(form).each(function(index) {
                    if (this.name == "phone_number") {
                        phoneNumber = this.value;
                    }
                    if (this.name == "captcha_number") {
                        captchaNumber = this.value;
                    }
                    if (this.name == "real_name") {
                        realName = this.value;
                    }
                    if (this.name == "address") {
                        address = this.value;
                    }
                    if (this.name == "idcode") {
                        idcode = this.value;
                    }
                });

                if (checkForm.phoneNumber(phoneNumber) &&
                        checkForm.captchaNumber(captchaNumber) &&
                        checkForm.realName(realName)&&
                        checkForm.address(address)) {
                    $.ajax({
                        url : "{:U('Huodong/api/saveUserInfo')}",
                        cache : false,
                        type : "POST",
                        dataType : "json",
                        data : form,
                        success : function(msg, textStatus){
                            if (msg.errcode == 0) {
                                if (msg.data.status == 0) {
                                    $('.personal_info').hide();
                                    showNotice();
                                    return;
                                }
                                alert('个人信息提交失败，请稍后重新提交');
                            }
                        },
                        error : function(){
                            alert('个人信息提交失败，请稍后重新提交');
                        }
                    });
                } else {
                    alert("表单填写错误");
                }
            }
        }

        //
        setTimeout(function(){
            $(document.body).append($('<img class="invisible" src="{:C('IMG_PATH')}static/hd/oly/bbt2.png" />'));
            $(document.body).append($('<img class="invisible" src="{:C('IMG_PATH')}static/hd/oly/bbt3.png" />'));
            for (var i = 0; i < frameList.length; i++) {
                $(document.body).append($('<img class="invisible" src="{:C('IMG_PATH')}static/hd/oly/' + frameList[i] + '.png" />'));
            }
        }, 1000);
    })();
</script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script>
    var names = ['学神', '神枪手', 'Super Dan', 'MVP', '颜王', '飞毛长腿', '无影手', '牛B的飞鱼'];
    var titles = ['中国爆给力的你会获得什么爆给力的奖品？百分百中奖哦', '我是［{$user_info.nickname}］：获得了[ggg]，快去看看中国爆给力的你获得了什么爆给力的奖品？百分百中奖哦'];
    var pics = [
        "{:C('IMG_PATH')}static/hd/oly/share_f",
        "{:C('IMG_PATH')}static/hd/oly/share_d",
        "{:C('IMG_PATH')}static/hd/oly/share_g",
        "{:C('IMG_PATH')}static/hd/oly/share_a",
        "{:C('IMG_PATH')}static/hd/oly/share_h",
        "{:C('IMG_PATH')}static/hd/oly/share_e",
        "{:C('IMG_PATH')}static/hd/oly/share_b",
        "{:C('IMG_PATH')}static/hd/oly/share_c"
    ];
    var contents = ['经抱抱堂学霸联盟鉴定，你上知天文能捡瓦下知地理会掏沟，爆聪明！快去向小伙伴炫耀一下！',
        '经抱抱堂射击联盟鉴定，你神枪手附身，爆精准！快去向小伙伴炫耀一下！',
        '经抱抱堂羽毛球协会鉴定，你的扣杀完爆对手，爆精彩！快去向小伙伴炫耀一下！',
        '经BBA（抱抱堂职业篮球联赛）鉴定，你的三分球每投必中，爆完美！快去向小伙伴炫耀一下！',
        '经抱抱堂颜值委员会鉴定，你拥有逆天颜值，爆美腻！快去向小伙伴炫耀一下！',
        '经抱抱堂飞毛腿委员会鉴定，你跑赢了博尔特，腿爆长！快去向小伙伴炫耀一下！',
        '经抱抱堂X友协会鉴定，骚年，这手没白练呀，爆迅速！快去向小伙伴炫耀一下！',
        '经抱抱堂鱼塘鉴定，你的泳技赢了飞鱼，爆牛B！快去向小伙伴炫耀一下！'];

    var latitude = 0;
    var longitude = 0;

    var env = {};
    env.appid = "{$js_sign['appId']}";
    env.timestamp = "{$js_sign['timestamp']}";
    env.nonceStr = "{$js_sign['nonceStr']}";
    env.signature = "{$js_sign['signature']}";
    env.openid = "{$openid}";
    env.cardid = "{$cardid}";
    env.jscard = {};
    env.jscard.timestamp = "{$jscard_sign['timestamp']}";
    env.jscard.nonceStr = "{$jscard_sign['nonceStr']}";
    env.jscard.signature = "{$jscard_sign['signature']}";

    env.bbtTitle = titles[0];
    env.link = 'http://' + document.domain + '/index.php?g=Huodong&m=Index&a=index&activityid=1000000';
    env.imgUrl = "{:C('IMG_PATH')}static/hd/oly/200.jpg";

    wx.config({
        debug: false,
        appId: env.appid, // 必填，公众号的唯一标识
        timestamp: env.timestamp, // 必填，生成签名的时间戳，切记时间戳是整数型，别加引号
        nonceStr: env.nonceStr, // 必填，生成签名的随机串
        signature: env.signature, // 必填，签名，见附录1
        jsApiList: [
            'checkJsApi',
            'addCard',
            'chooseCard',
            'openCard',
            'onMenuShareTimeline',
            'onMenuShareAppMessage'
//            ,'getLocation'
        ]
    });
    wx.ready(function () {
        enrolMenu();
    });

    function enrolMenu(){
        wx.onMenuShareTimeline({
            title: (env.bbtTitle),
            link: env.link,
            imgUrl: env.imgUrl,
            trigger: function (res) {
                //alert('用户点击分享到朋友圈');
            },
            success: function (res) {
                //alert('已分享');
            },
            cancel: function (res) {
                //alert('已取消');
            },
            fail: function (res) {
                //alert(JSON.stringify(res));
            }
        });
        //alert('已注册获取“分享到朋友圈”状态事件');

        wx.onMenuShareAppMessage({
            title: '中国爆给力',
            link: env.link,
            imgUrl: env.imgUrl,
            desc: env.bbtTitle, // 分享描述
            type: 'link', // 分享类型,music、video或link，不填默认为link
            dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
            success: function () {
                // 用户确认分享后执行的回调函数
            },
            cancel: function () {
                // 用户取消分享后执行的回调函数
            }
        });

//        wx.getLocation({
//            type: 'wgs84', // 默认为wgs84的gps坐标，如果要返回直接给openLocation用的火星坐标，可传入'gcj02'
//            success: function (res) {
//                latitude = res.latitude; // 纬度，浮点数，范围为90 ~ -90
//                longitude = res.longitude; // 经度，浮点数，范围为180 ~ -180。
//                var speed = res.speed; // 速度，以米/每秒计
//                var accuracy = res.accuracy; // 位置精度
//            }
//        });
    }
</script>
</html>